import http from './http'

// 获取今日新闻列表(含轮播图数据)
export const queryNewsLatest = () => http.get('/news_latest');

// 获取往日新闻列表
export const queryNewsBefore = (time) => {
    return http.get('/news_before', {
        params: {
            time
        }
    });
};

// 获取新闻详细信息
export const queryNewsInfo = (id) => {
    return http.get('/news_info', {
        params: {
            id
        }
    });
};

// 获取新闻评论点赞信息
export const queryStoryExtra = (id) => {
    return http.get('/story_extra', {
        params: {
            id
        }
    });
};

// 用户登录
export const userLogin = (phone, code) => {
    return http.post('/login', {
        phone,
        code
    });
};

// 发送验证码
export const userPhoneCode = (phone) => {
    return http.post('/phone_code', {
        phone
    });
};

// 获取登录者信息
export const queryUserInfo = () => http.get('/user_info');

// 修改用户信息
export const userUpdate = (username, file) => {
    let fm = new FormData;
    fm.append('username', username);
    fm.append('file', file);
    return http.post('/user_update', fm);
};

// 收藏新闻
export const userStore = (newsId) => {
    return http.post('/store', {
        newsId
    });
};

// 移除收藏
export const userStoreRemove = (id) => {
    return http.get('/store_remove', {
        params: {
            id
        }
    });
};

// 获取收藏列表
export const userStoreList = () => http.get('/store_list');